home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / dl_exsrc.zoo / getcook.c < prev    next >
C/C++ Source or Header  |  1994-07-03  |  627b  |  39 lines

  1. #include <osbind.h>
  2.  
  3. /* Cookie-reading program "borrowed" from the MiNTlibs startup
  4.    code -- 6/27/94 sb */
  5.  
  6. static long getcook __PROTO((void));
  7.  
  8. static long work;
  9.  
  10. static long getcook()
  11. {
  12.     register long *cookie;
  13.     register long key = work;
  14.  
  15.     cookie = *((long **) 0x5a0L);
  16.     if (!cookie)
  17.         return 0;
  18.     else {
  19.         while (*cookie) {
  20.             if (*cookie == work) {
  21.                 work = cookie[1];
  22.                 return 1;
  23.             }
  24.             cookie += 2;
  25.         }
  26.     }
  27.     return 0;
  28. }
  29.  
  30. int Getcookie( long cookie, long *value )
  31. {
  32.     work = cookie;
  33.     if (Supexec(getcook)) {
  34.     if (value)
  35.         *value = work;
  36.     return 1;
  37.     } else return 0;
  38. }
  39.